const { Controller } = require('egg')

class WechatController extends Controller {
  /**
     * @api {get} /wechat/min/access-token [微信小程序] 获取Access token
     * @apiGroup 账号
     * @apiVersion 0.0.0
     * 
     * @apiSuccess {Int} code 状态码 <br /> 0、成功 <br /> 1、失败
     * @apiSuccess {String} msg  success
     * @apiSuccess {Object} data
     * 
     * @apiSuccessExample {json} Success-Response:
    {
        "code": 0,
        "msg": "success"
    }
     */
  async getAccessToken() {
    const { ctx } = this
    const accessAoken = await this.service.config.getMiniProgramAccessToken()

    ctx.body = {
      code: 0,
      msg: 'success',
      data: { accessAoken },
    }
  }
}

module.exports = WechatController
